package com.ql.service.yk;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import com.ql.dao.yk.YaopinMapper;
import com.ql.pojo.yk.PageResult;
import com.ql.pojo.yk.Yaopin;
import com.ql.pojo.yk.YaopinExample;
;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YaopinService {
    @Autowired
    private YaopinMapper yaopinMapper;


    public List<Yaopin> selectAll(){
        YaopinExample yaopinExample = null;
        List<Yaopin> yaopins  =yaopinMapper.selectByExample(yaopinExample);
        return yaopins;
    }

    /**
     * 返回分页列表
     * @return
     */
    public PageResult findPage(int pageNum, int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<Yaopin> yaopins = yaopinMapper.selectByExample(null);
        Page<Yaopin> page = (Page<Yaopin>) yaopins;
        return new PageResult(page.getTotal(),page.getResult());
    }
}
